package Gameplay;
import java.util.ArrayList;

import Gameplay.Enemy.Enemy;
/**
 * This class is a data structure including the a wave's 
 * information such as enemies in the wave, spawn time and 
 * wave time.
 * 
 * @author	Brian Wetherbee
 * 			Ryan McNamara
 * 			Zeng Yang
 *
 */
public class Wave {
	
	//an instance variable for storing enemies
	protected ArrayList<Enemy> enemyList = new ArrayList<Enemy>();
	int endWaveNum;
	long waveTime;
	long spawnTime;
	//@ public invariant endWaveNum >= -1;
	//@ public invariant waveTime >= -1;
	//@ public invariant spawnTime >= -1;
	
	//@ requires end >= 0;
	public Wave(int end) {
		endWaveNum = end;
		waveTime = -1;
		spawnTime = -1;
	}

	//@ requires end >= 0;
	public Wave(long end) {
		endWaveNum = -1;
		waveTime = end;
		spawnTime = System.currentTimeMillis();
	}
	
	//@ requires e != null;
	//@ ensures enemyList.contains(e) == true;
	public void addEnemy(Enemy e) {
		enemyList.add(e);
	}

	//@ requires e != null;
	//@ ensures enemyList.contains(e) == false;
	public void removeEnemy(Enemy e) {
		enemyList.remove(e);
	}
	
	//@ requires enemyList.size() > 0;
	public ArrayList<Enemy> getEnemyList() {
		return enemyList;
	}
	
	//Check if current wave is killed all by player.
	public boolean isFinished() {
		if(endWaveNum > -1) {
			if(enemyList.size() <= endWaveNum) {
				return true;
			}
			return false;
		}
		
		if(System.currentTimeMillis() >= spawnTime + waveTime) {
			return true;
		}
		return false;
	}
	
	
}
